module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
			// HTML压缩
			htmlmin: {
				task: {
					options: {
						removeComments: true,
						collapseWhitespace: true
					},
					expand: true,
					src: '*.html',
					dest: 'dist'
				}
			},
			// 编译Less文件
			less: {
				task: {
					
					src: 'less/web.less',
					dest: 'dist/core.css',
				}
			},
			// 自动加前缀
			autoprefixer: {
				task: {
					options: {
						browsers: [
							'Android 2.3',
							'Android >= 4',
							'Chrome >= 20',
							'Firefox >= 24',
							'Explorer >= 8',
							'iOS >= 6',
							'Opera >= 12',
							'Safari >= 6'
						]
					},
					src: 'dist/core.css',
				}
			},
			// JS语法错误检查
			jshint: {
					task:{
						src: 'js/*.js',
					}
				},
	
			// uglify:混淆压缩JS代码
			uglify: {
				options: {
					banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
				},
				build: {
					src: 'js/*',
					dest: 'dist/core.js',
				}
			},
			
			//动态监听
			watch:{
				files:['less/*.less','js/*.js'],
				tasks:['htmlmin','less','autoprefixer','jshint','uglify'],
			}
		});
		// 加载任务的插件。
		grunt.loadNpmTasks('grunt-contrib-htmlmin');
		grunt.loadNpmTasks('grunt-contrib-less');
		grunt.loadNpmTasks('grunt-autoprefixer');
		grunt.loadNpmTasks('grunt-contrib-jshint');
		grunt.loadNpmTasks('grunt-contrib-uglify');
		grunt.loadNpmTasks('grunt-contrib-watch');

		// 默认被执行的任务列表。
		grunt.registerTask('default', ['htmlmin','less','autoprefixer','jshint','uglify','watch'])

};